
import cv2
import cv2.cv as cv
imcolor = cv.LoadImage('fruits.jpg')
image = cv.LoadImage('fruits.jpg',cv.CV_LOAD_IMAGE_GRAYSCALE)
cornerMap = cv.CreateMat(image.height, image.width, cv.CV_32FC1)
# OpenCV corner detection
cv.CornerHarris(image,cornerMap,3)

for y in range(0, image.height):
 for x in range(0, image.width):
  harris = cv.Get2D(cornerMap, y, x) # get the x,y value
  # check the corner detector response
  #if harris[0] > 10e-06:
  if harris[0] > 10e-05:
   # draw a small circle on the original image
   #cv.Circle(imcolor,(x,y),2,cv.RGB(155, 0, 25))
   cv.Circle(imcolor,(x,y),2,cv.RGB(155, 0, 25))


##   value=cv.Get2D(image,y,x)
##   cv.Set2D(image,y,x,value)
   #########################################



cv.NamedWindow('Harris', cv.CV_WINDOW_AUTOSIZE)
cv.ShowImage('Harris', imcolor) # show the image
cv.SaveImage('harris.jpg', imcolor)
cv.WaitKey()

##cv.SetImageROI(image, (40,40,50,50))
##template=cv.CloneImage(image)
##cv.NamedWindow('Harris_crop', cv.CV_WINDOW_AUTOSIZE)
##cv.ShowImage("template.jpg",template)
##cv.WaitKey()
